package org.jeecgframework.web.sms.util.task;

import java.util.Date;

import org.apache.tools.ant.util.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.yngrp.service.wo.GroupPowerRateService;
import com.yngrp.util.Constant;

/**
 * 
 * @ClassName:CreatePowerQueryTask 生成电费查询任务定时任务类
 * @Description: TODO
 * @author SLH
 * @date 2016-08-21 
 * 
 */
@Service("createPowerQueryTask")
public class CreatePowerQueryTask {
	
	@Autowired
	private GroupPowerRateService groupRateService;
	
	/*@Scheduled(cron="0 0/1 * * * ?")*/
	public void run() {
		long start = System.currentTimeMillis();
		org.jeecgframework.core.util.LogUtil.info("===================消息中间件定时任务开始===================");
		try {
			String message = "";
			String queryDay = DateUtils.format(new Date(), Constant.FORMART_QUERY_DAY);
			
			if(groupRateService.checkQueryTask(queryDay)){
				String rMsg = groupRateService.createQueryTask(queryDay, Constant.AUTO_CREATE_MODE);
				if(rMsg.equals(Constant.SUCCESS)){
					message = queryDay+"电费查询任务生成成功";
					org.jeecgframework.core.util.LogUtil.info("==================="+message+"===================");
				}				
			}
			 
		} catch (Exception e) {
		    e.printStackTrace();
		}
		org.jeecgframework.core.util.LogUtil.info("===================消息中间件定时任务结束===================");
		long end = System.currentTimeMillis();
		long times = end - start;
		org.jeecgframework.core.util.LogUtil.info("总耗时"+times+"毫秒");
	}
}
